package com.lyouu.dataminer.util;

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.Interval;

public class DateTest {
	public static void main(String[] args) throws ParseException {
		// Date past = new Date(116, 2, 27); // June 20th, 2010
		// Date today = new Date(116, 3, 1); // July 24th
		// int days = Days.daysBetween(new DateTime(past), new DateTime(today))
		// .getDays();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		DateTime start = new DateTime(2016, 2, 27, 0, 0, 0);
		DateTime end = new DateTime(2016, 3, 1, 0, 0, 0);
		int days = Days.daysBetween(start, end).getDays();
		System.out.println(days);

		String startDate = "2014-08-16";
		String endDate = "2015-05-16";
		start = new DateTime(sdf.parse(startDate));
		end = new DateTime(sdf.parse(endDate));
		days = Days.daysBetween(start, end).getDays();
		System.out.println(days);

		String d1 = "2016-02-01";
		String d2 = "2014-09-02";

		Date date1 = (Date) sdf.parse(d1);
		Date date2 = (Date) sdf.parse(d2);
		Calendar calendar = new GregorianCalendar();
		calendar.setTime(date1);
		System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
		calendar.setTime(date2);
		System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
	}
}
